package com.yupi.shortchain.service;

import com.yupi.shortchain.common.DeleteRequest;
import com.yupi.shortchain.model.dto.urlrelate.UrlRelateAddRequest;
import com.yupi.shortchain.model.dto.urlrelate.UrlRelateUpdateRequest;
import com.yupi.shortchain.model.entity.UrlRelate;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* @author liu
* @description 针对表【url_relate(链接关系表)】的数据库操作Service
* @createDate 2024-12-04 08:23:48
*/
public interface UrlRelateService extends IService<UrlRelate> {
    /**
     * @param urlRelateAddRequest
     * @return
     */
    Long addUrlRelate(UrlRelateAddRequest urlRelateAddRequest);

    /**
     * 将长链转化为短链  返回短链
     * @param longUrl
     * @return
     */
    String addUrlRelate(String longUrl);

    /**
     * 校验长链
     * @param urlRelate
     * @param add
     */
    void validUrlRelate(UrlRelate urlRelate, boolean add);

    /**
     * 通过短链获取长链
     * @param shortUrl
     * @return
     */
    UrlRelate getLongLink(String shortUrl);

    /**
     * 删除长链关系
     *
     * @param deleteRequest
     * @return
     */
    boolean deleteUrlRelate(DeleteRequest deleteRequest);

    /**
     * 更新长链关系
     *
     * @param urlRelateUpdateRequest
     * @return
     */
    boolean updateUrlRelate(UrlRelateUpdateRequest urlRelateUpdateRequest);
}
